package com.bowen.factory;

import com.bowen.security.rsa.Client;
import com.bowen.security.rsa.factory.RasFactoryExcute;
import com.bowen.security.rsa.upstream.UpStreamClient;

/**
 * 工厂 所有函数入口
 * 
 * @author Bowen
 * @since 2021-12-02 15:28:43
 */
public class Factory {

  /**
   * 操作入口
   * 
   * @return RasFactory
   */
  public static com.bowen.security.rsa.factory.RasFactory RAS() {
    return new com.bowen.security.rsa.factory.RasFactory();
  }

  /**
   * * 初始化 权限 Mysql版本 只支持下游系统
   * 
   * <pre>
   * 在使用Rsa接口时. 必须要 先调用该方法一次 不支持ssh
   * </pre>
   * 
   * @param url             数据库链接
   * @param username        账号
   * @param password        密码
   * @param driverClassName 驱动
   * @return RasFactoryExcute.class
   * @throws Exception Exception
   */
  public static RasFactoryExcute init(String url, String username, String password, String driverClassName)
      throws Exception {
    return RasFactoryExcute.init(url, username, password, driverClassName);
  }

  /**
   * 当前为上游系统 初始化数据
   * 
   * @param downStreamPublicKey 下游公钥
   * @param upStreamPrivateKey  上游私钥
   * @return Client
   */
  public static Client initUp(String downStreamPublicKey, String upStreamPrivateKey) {
    return UpStreamClient.getUpStreamClient().setDownStreamPublicKey(downStreamPublicKey)
        .setUpStreamPrivateKey(upStreamPrivateKey);
  }

}
